import http from '../../tool/http'


const state={
    AllStaff:[],
    getCurrentDataA:[
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,

    ],
    searchCurrentDataA:[
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
        {work_day:'2020-1-1',time_slot:'8：00—14：00',staff_id:'张三'} ,
    ],
    getCurrentDataC:[
        {number:'1',people_num:'8',state:'可用',type:'大桌'} ,
        {number:'2',people_num:'1',state:'不可用',type:'大桌'} ,
        {number:'3',people_num:'2',state:'可用',type:'大桌'} ,
        {number:'4',people_num:'4',state:'可用',type:'圆桌'} ,
        {number:'5',people_num:'9',state:'可用',type:'大桌'} ,
    ],
    searchCurrentDataC:[
        {number:'1',people_num:'8',state:'可用',type:'大桌'} ,
    ],
    getCurrentDataD:[
        {user_id:'1'} ,
        {user_id:'2'} ,
        {user_id:'3'} ,
        {user_id:'4'} ,
        {user_id:'5'} ,
    ],
    searchCurrentDataD:[
        {user_id:'1'} ,
    ],
}
const actions={
    getAllStaff({commit}){
        return http({
            url:'/getAllStaff',
            method:'post',
        }).then(res=>{
            commit('addAllStaff',res.data)
        })
    } ,
    getCurrentDataA({commit},pageNum){
        return http({
            url:'/GetArrange',
            method:'post',
            data:{pageNum}
        }).then(res=>{
            commit('addGetDataA',res.data)
            return 200
        })
    } ,
    searchCurrentDataA(context,data){
        // console.log(data)
        let name=data.name
        let classify_id=data.classify_id
        let pageNum=data.pageNum
        return http({
            url:'/SearchArrange',
            method:'post',
            data:{name:name,classify_id: classify_id,pageNum:pageNum}
        }).then(res=>{
            context.commit('addSrarchDataA',res.data)
            return 200
        })
    },
    getCurrentDataC({commit},pageNum){
        return http({
            url:'/GetSeats',
            method:'post',
            data:{pageNum}
        }).then(res=>{
            commit('addGetDataC',res.data)
            return 200
        })
    } ,
    searchCurrentDataC(context,data){
        // console.log(data)
        let number=data.number
        return http({
            url:'/SearchSeats',
            method:'post',
            data:{number:number}
        }).then(res=>{
            context.commit('addSrarchDataC',res.data)
            return 200
        })
    },
    getCurrentDataD({commit},pageNum){
        return http({
            url:'/GetSeats',
            method:'post',
            data:{pageNum}
        }).then(res=>{
            commit('addGetDataC',res.data)
            return 200
        })
    } ,
    searchCurrentDataD(context,data){
        // console.log(data)
        let number=data.number
        return http({
            url:'/SearchSeats',
            method:'post',
            data:{number:number}
        }).then(res=>{
            context.commit('addSrarchDataC',res.data)
            return 200
        })
    },
}
const mutations={
    addGetDataA(state,data){
        state.getCurrentDataA=data
        // console.log(state.getCurrentData)
    } ,
    addSrarchDataA(state,data){
        state.searchCurrentDataA=data
    },
    addGetDataC(state,data){
        state.getCurrentDataC=data
        // console.log(state.getCurrentData)
    } ,
    addSrarchDataC(state,data){
        state.searchCurrentDataC=data
    },
    addGetDataD(state,data){
        state.getCurrentDataC=data
        // console.log(state.getCurrentData)
    } ,
    addSrarchDataD(state,data){
        state.searchCurrentDataC=data
    },
    addAllStaff(state,data){
        state.AllStaff=data
    },

}
const getters={

}


export default {
    state,
    actions ,
    mutations,
    getters
}


